#ifndef __INCtimerh
#define __INCtimerh
#include <chrono>
#include <functional>
#include <mutex>
#include <thread>
#include <condition_variable>
#include <declarecClass.h>
#include <task.h>

class Timer 
{
public:
    using Callback = std::function<void()>;
    Timer(const char* objTimerName, unsigned int intervalMs, Callback callback);
    ~Timer();
    void start();
    void stop();
    void reset();
    bool isRunning() const;
    void run(TaskPtr);
    int  getInterval();
    std::string& getName();

private:
    DISABLE_COPY_CLASS(Timer);

private:
    const unsigned int m_intervalMs;
    Callback m_callback;
    std::mutex m_mutex;
    std::condition_variable m_cv;
    bool m_needReset;
    bool m_abort;
    std::string m_timerName;
    TaskPtr m_taskThread;
};

#endif
